//
//  sortScrollV.m
//  SAT_NET
//
//  Created by lanou3g on 16/3/2.
//  Copyright © 2016年 郭丹. All rights reserved.
//

#import "sortScrollV.h"

@implementation sortScrollV

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


- (instancetype)initWithSortArray:(NSMutableArray *)sortArray buttonWidth:(CGFloat )buttonWidth frame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentSize = CGSizeMake(sortArray.count * buttonWidth, frame.size.height);
        // 回弹效果
        self.bounces = YES;
        self.backgroundColor = [UIColor colorWithRed: 45 / 255.0
                                               green: 128 / 255.0
                                                blue: 248 / 255.0
                                               alpha:1];
        self.showsHorizontalScrollIndicator = NO;
        
        for (int i = 0; i < sortArray.count; i ++) {
            UIButton *button = [UIButton buttonWithType:(UIButtonTypeSystem)];
//            button.backgroundColor = [UIColor redColor];
            [button setFrame:CGRectMake(buttonWidth * i, 20, buttonWidth, frame.size.height - 20)];
            [button setTitle:sortArray[i] forState:(UIControlStateNormal)];
            [button setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
            [self addSubview:button];
        }
    }
    return self;
}






@end
